/**
 * @project：FODB rest请求接口
 * @title：FODBRestClient.java
 * @description：
 * @package com.serial.comm.core.rest.fodb
 * @author：scylla
 * @date：2020/6/19
 * @copyright: 武汉中天云通数据科技有限责任公司  All rights reserved.
 * @version V1.0
 */
package com.serial.comm.core.rest.fodb;

import com.alibaba.fastjson.JSONObject;
import com.serial.comm.core.utils.RestUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@Component
public class FODBRestClient {

    public static final String FODB_WIRTE_REQUIRE_API = "http://127.0.0.1/messageApi/updateStatus";
    public static final int CONNEC_TIMEOUT = 5000;
    public static final int READ_TIMEOUT = 10000;
    public static final int RETRY_COUNT = 3;

    public static Map<String, Object> headerMap = new HashMap<>();


    public static final String CONTENT_TYPE = "Content-Type";

    public static final String APPLICATION_JSON = "application/json";

    static {
        headerMap.put(CONTENT_TYPE, APPLICATION_JSON);
    }

    /**
     * @title: fodbRequireApi
     * @description: 请求 fodb反馈接口
     * @author: scylla
     * @date: 2020/6/19 10:27 上午
     * @param: [message status sid]
     * @return: java.lang.String
     */
    public String fodbRequireApi(String message, String status, String sid) {
        JSONObject param = new JSONObject();
        param.put("message", message);
        param.put("sid", sid);
        param.put("status", status);
        Map<String, String> header = new HashMap<>();
        header.put("Content-Type", "application/json");
        String result = RestUtils.postHttp(FODB_WIRTE_REQUIRE_API, param, header, CONNEC_TIMEOUT, READ_TIMEOUT, RETRY_COUNT);
        return result;
    }


}
